home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / scanasc.zip / SCANASC.DOC next >
Text File  |  1991-10-19  |  14KB  |  249 lines

  1.                              SCANASC.DOC
  2.  
  3.      SCANASC is a programmer's tool for quickly determining the scan
  4. and ASCII codes of any key placed in the keyboard buffer by the ROM
  5. BIOS.  Code values are given in both decimal and hex.  SCANASC
  6. distinguishes between PC and enhanced keyboards and reports whether
  7. the key is available only on the enhanced keyboard.  Since codes are
  8. like peanuts and potato chips--one rarely satisfies--SCANASC also
  9. offers a List Mode.  In List Mode SCANASC prepares a list of all the
  10. keys you press in a session, their scan and ASCII codes, and
  11. identifies those that are available only on the enhanced keyboard.
  12.  
  13.      The syntax for running SCANASC is:
  14.  
  15.                      SCANASC [/M] [/L] [/H] [/?]
  16.  
  17.      /H or /? for help.
  18.  
  19.      /M to force SCANASC to run in monochrome when you have a color
  20.      monitor.
  21.  
  22.      /L to operate SCANASC in List Mode.  In List Mode, SCANASC
  23.      prepares a list of the scan and ASCII codes for all keystrokes
  24.      pressed.  Output is placed in a file entitled SCANASC.LST in the
  25.      default directory.  If SCANASC.LST exists, new output will be
  26.      appended to the end of the list.  SCANASC.LST is presented in the
  27.      following sample format:
  28.  
  29.                                   SCANASC.LST
  30.  
  31.                                       Hex              Decimal
  32. Key                               Scan   ASCII       Scan   ASCII       Enhanced
  33. ----------------------------      ----   -----       ----   -----       --------
  34.  
  35. q                                  10     71           16    113
  36. Backspace                          0E     08           14      8
  37. Num-Enter                          E0     0D          224     13               √
  38. Home                               47     00           71      0
  39. Cursor Pad Home                    47     E0           71    224               √
  40. F12                                86     00          134      0               √
  41. Alt-F10                            71     00          113      0
  42. Alt-Esc                            01     00            1      0               √
  43. Ctrl-Numeric Keypad Center         8F     00          143      0               √
  44. Alt-Numeric Keypad ({)             00     7B            0    123
  45. Shift-F11                          87     00          135      0               √
  46. Numeric Keypad-5                   4C     35           76     53
  47.  
  48.  
  49.      To exit SCANASC, press Esc twice.  The first time Esc is pressed
  50. the scan and ASCII codes for Esc are reported.  The second key press
  51. exits the program.  If you do not wish to exit, but merely wish to
  52. determine the Scan and ASCII codes for Esc, press any other key to
  53. continue.  Incidentally, although Ctrl-Esc and Shift-Esc generate the
  54. same scan and ASCII codes as Esc (see below for more on this subject),
  55. you must press Esc in its unshifted state to exit SCANASC.
  56.  
  57.  
  58.      When you run SCANASC, it first determines whether you have an
  59. enhanced keyboard.  If an enhanced keyboard is detected, a notice
  60. "Enhanced Keyboard Detected" will appear, followed by box labelled
  61. "Enhanced Key".  If a key is available only on the enhanced keyboard,
  62. a check mark (√) will appear in the box when the key is pressed.
  63.  
  64.      The preceding examples from SCANASC.LST also demonstrate the
  65. terminology employed by SCANASC to identify key names.  The cursor
  66. positioning keys on the numeric keypad are named without prefix.  The
  67. corresponding keys on the enhanced keyboard cursor pad are prefixed
  68. "Cursor Pad".  The middle key on the numeric keypad in its unshifted
  69. state does not have a name.  SCANASC calls it Numeric Keypad Center.
  70. It is only recognized on enhanced keyboards.  The numeric keys on the
  71. keypad (i.e. when Num Lock is on or Shift is pressed, but not both)
  72. are prefixed with "Numeric Keypad-" to distinguish them from the
  73. numeric keys on the top row of the keyboard.  Alt-Numeric Keypad ( )
  74. refers to keys entered by holding down the Alt key and entering a
  75. number between 1 and 255 on the numeric keypad.  The ASCII character
  76. generated by this procedure is given in parenthesis.  The scan code
  77. will always be 0 and the ASCII code will always be the number entered
  78. on the numeric keypad.
  79.  
  80.      Since SCANASC mirrors the idiosyncrasies of the ROM BIOS in terms
  81. of keyboard translation, a few comments on those peculiarities may be
  82. in order.  The ROM BIOS does not recognize certain keys.  For example,
  83. although Ctrl-2, Ctrl-6, and Ctrl-_ are recognized, the other
  84. printable keys on the top row of the keyboard are not recognized in
  85. connection with the Ctrl key.  Thus, if you press Ctrl-3 while in
  86. SCANASC, nothing will happen.  Other examples of unrecognized keys are
  87. Ctrl-; and Ctrl-'.  The only way to detect these keystrokes is through
  88. interrupt 09H.
  89.  
  90.      In some cases, the ROM BIOS will translate a key press as
  91. unshifted, regardless of shift state.  For example, Ctrl-Space, Shift-
  92. Space, and Alt-Space are all interpreted as Space.  Likewise, SCANASC
  93. interprets each of these keys as "Space".  Thus if you see that
  94. SCANASC reports a shifted keystroke as if it were unshifted, this is a
  95. cue that your program must independently check the shift state of the
  96. key, either through one of the services offered by interrupt 16H, or
  97. by examining the byte at 0040:0017H.  Another example of disregarding
  98. shift state occurs with Esc; Shift-Esc and Ctrl-Esc are both treated
  99. as Esc.  On an enhanced keyboard, however, Alt-Esc does generate a
  100. unique code.
  101.  
  102.      The ROM BIOS does not translate unique codes for shift key
  103. combinations.  Thus, if you press Ctrl-Alt-S, the ROM BIOS does not
  104. generate a unique code.  In my experience, the ROM BIOS observes the
  105. following hierarchy:  Alt, Ctrl, Shift.  Thus, if Alt is pressed, it
  106. takes precedence over both Ctrl and Shift.  In the preceding example,
  107. Ctrl-Alt-S would be treated as Alt-S.  Having seen no mention of this
  108. in the literature I have examined, I cannot say whether these
  109. priorities constitute an absolute rule or represent the rules followed
  110. by the BIOS on my own computer.
  111.  
  112.      On some keyboards pressing two shift keys simultaneously will
  113. inhibit the keyboard from generating a scan code for a printable key.
  114. For example, on my Northgate keyboard, pressing Ctrl-Shift-Y
  115. suppresses the generation of the Y scan code by the keyboard.  On the
  116. other hand, Ctrl-Shift-I is recognized.  There is no way for a
  117. programmer to detect when a keystroke is inhibited in this fashion.
  118. Even trapping interrupt 9H will be of no avail. That may be the price
  119. one pays for having function keys on the left.
  120.  
  121.      SCANASC was written as an unintentional by-product of my program
  122. MALT.  MALT (More Alt-Keys for the Perfects) is a TSR that adds 90 new
  123. keys to WordPerfect and other members of the Perfect family for
  124. running Alt-like macros.  To avoid conflicts with other TSRs, MALT
  125. uses CapsLock + Key.  In order for MALT to operate properly, it must
  126. know if the user has reassigned the WordPerfect's "Macro Execute" key
  127. (WordPerfect has a configurable keyboard), and, if so, to which key it
  128. has been reassigned.  I would guess that an infinitesimally small
  129. number have reassigned this key, but, since I happen to be among that
  130. small number, and, of course, in the interest of completeness, I wrote
  131. a configuration program (MALTCFG) to allow for the customization of
  132. MALT.
  133.  
  134.      As it turned out, more effort was spent on MALTCFG than on MALT
  135. itself.  This is because MALTCFG had to recognize and interpret every
  136. possible key supported by the ROM BIOS.  Although information on
  137. keyboard scan codes is readily available, none of the authorities I
  138. consulted had a complete list of all the ROM BIOS scan and ASCII
  139. codes.  Not only was a list unavailable, but the assignment of the
  140. codes does not follow any consistent logic, making it impossible in
  141. many cases to deduce what a code should be.  To remedy this
  142. deficiency, I prepared a crude form of SCANASC.  It seemed wasteful to
  143. have spent all that effort on a program that few would use, so I
  144. decided to develop SCANASC for the programming community.
  145.  
  146.      Incidentally, after I completed MALTCFG, I discovered that the
  147. setup procedure in the AMI BIOS has a keyboard utility that also
  148. reports scan and ASCII codes.  Inasmuch as the setup is in ROM, can
  149. only be accessed by rebooting the computer, and has no List Mode,
  150. there is probably still a place for SCANASC.
  151.  
  152.      SCANASC is principally written in Microsoft Professional
  153. Development System (PDS) BASIC 7.10, using routines contained in
  154. Crescent Software's QuickPak Professional, and linked with Crescent's
  155. P.D.Q.  It also contains custom assembler routines by the author for
  156. retrieving keystrokes.  I would be unforgivably remiss if I failed to
  157. underscore the importance of Crescent's products in the development of
  158. this program.  The fully commented assembly language source code
  159. included with the Crescent products provided instructive examples for
  160. the assembly language routines needed for SCANASC.  An indispensable
  161. education in assembly language programming was provided by Ethan
  162. Winer's book "BASIC Techniques and Utilities".
  163.  
  164.      I drew on a number of reference sources detailing the operation
  165. of the keyboard and the ROM BIOS in connection with the preparation of
  166. this program.  Of these, by far the most instructive was the article
  167. by Michael J. Mefford entitled "An In-depth Exploration of the PC
  168. Keyboard and its Interrupt Service Routines", which appeared in the
  169. May 1990 issue of Microsoft Systems Journal (Volume 5, Number 3).  His
  170. method for detecting the presence of an enhanced keyboard is
  171. incorporated in SCANASC.  Also very useful were the pair of articles
  172. by Barry Simon (someone for whom I have a deep admiration because of
  173. his work on CTRLALT and STACKEY) entitled "Learning Your Way Around
  174. the Keyboard under DOS", which appeared in the December 25, 1990 and
  175. January 15, 1991 issues of PC Magazine (Volume 9, Number 22 and Volume
  176. 10, Number 1).  His program BIOSDATA, which was distributed with the
  177. articles, was especially helpful in deciphering the operation of the
  178. PC keyboard BIOS.
  179.  
  180.      Two other informative resources were "DOS Programmer's Reference
  181. (2nd Edition)", by Terry Dettmann and Jim Kyle, and "The New Peter
  182. Norton Programmer's Guide to the IBM PC & PS/2", by Peter Norton and
  183. Richard  Wilton.  I also referred frequently to "Advanced MS-DOS
  184. Programming (Second Edition)", by Ray Duncan, but not for keyboard
  185. information.
  186.  
  187.      There is no charge or registration fee for the use of SCANASC.  I
  188. have benefited from many publicly distributed free programs and this
  189. is a small way of reciprocating.  I would enjoy hearing from anyone
  190. who finds this program useful.  I would particularly welcome
  191. notification of any errors or omissions and suggestions for
  192. improvement of the program.
  193.  
  194.      If you use, or know of someone else who uses, WordPerfect, you
  195. may wish to investigate my user supported programs.  MALT has already
  196. been described.  In addition, I am the author of MPE4WP (Macro
  197. Programming Environment for WordPerfect), a substitute for the
  198. WordPerfect macro editor.  MPE4WP permits the creation and editing of
  199. macros on the WordPerfect editing screen or in any ASCII text editor.
  200. MPE4WP includes programs that convert macros to and from text, macros
  201. that improve upon the features of the macro editor, and enhancements
  202. to the macro language.
  203.  
  204.      This document and the program file SCANASC.EXE (the documentation
  205. and program file are collectively referred to as the "Software") are
  206. copyrighted by the author.  You are licensed to use the Software; make
  207. as many copies of the Software as you wish; give unaltered copies to
  208. anyone; and distribute the Software via electronic means.  There is no
  209. charge for any of these uses.
  210.  
  211.      You are, however, specifically prohibited from modifying the
  212. Software or from distributing only a portion of it; charging, or
  213. requesting donations, for any such copies; and from distributing the
  214. Software with commercial products without prior permission.  An
  215. exception is granted to not-for-profit user's groups, which are
  216. authorized to charge a small fee for materials, handling, postage, and
  217. general overhead.  No for-profit organization is authorized to charge
  218. any amount for distribution of copies of the software, or to include
  219. copies of the software with sales of its products.
  220.  
  221.      This includes a specific prohibition against for-profit
  222. organizations distributing the software, either alone or with other
  223.  
  224. software, and charging a "handling" or "materials" fee or any other
  225. such fee for the distribution.  No for-profit organization is
  226. authorized to include the software on any mediium for which money is
  227. charged.  The preceding prohibition should not be construed as
  228. applying to CompuServe, PCMagNet, or other similar services that have
  229. general charges for connect time, and do not surcharge for downloading
  230. this program.
  231.  
  232.      There is no restriction on the use of the Software in commercial
  233. or institutional environments.
  234.  
  235.      The documentation and program file must be distributed together,
  236. and this notice must not be removed.
  237.  
  238.      By using this free Software, you agree that there is no warranty
  239. of any kind, and the author is not liable to you or anyone else for
  240. damages of any kind.
  241.  
  242.      The Software is:
  243.  
  244.                         Copyright (c) 1991 by
  245.                           Michael H. Shacter
  246.                            7825 Marion Lane
  247.                        Bethesda, Maryland 20814
  248.                        CompuServe ID 76170,1627
  249.